<?php
//~ header('Content-Type: text/xml');
include "fonctions.php";

if (isset($_POST['id']) && isset($_POST['etat'])) {
	
echo $_POST['etat'];
		db_connect();
		
		$req = "SELECT etat FROM LMLP.articles WHERE idArticle =".$_POST['id'].";";
		$res  = mysql_query($req) or die (mysql_error());
		while ($row = mysql_fetch_assoc($res)) {
			if($row['etat']=="Vitrine attente"){
				$req = "UPDATE articles SET etat = 'Vitrine' WHERE articles.idArticle=".$_POST['id'].";";
				$res  = mysql_query($req) or die (mysql_error());
				echo $res;
			}else{
				$req = "UPDATE articles SET etat = '".$_POST['etat']."' WHERE articles.idArticle=".$_POST['id'].";";
				$res  = mysql_query($req) or die (mysql_error());
				echo $res;
			}
		}
		}else{
			echo "Erreur";
		}

?>
